<template>
  <transition :name="disableTransitions ? '' : 'ys-zoom-in-center'">
    <span
      class="ys-tag"
      :class="[
        type ? 'ys-tag--' + type : '',
        theme ? 'ys-tag--' + theme : '',
        tagSize && `ys-tag--${tagSize}`,
        { 'is-hit': hit },
      ]"
      :style="{ backgroundColor: color }"
    >
      <slot></slot>
      <i
        class="ys-tag__close ys-icon-close"
        v-if="closable"
        @click.stop="handleClose"
      ></i>
    </span>
  </transition>
</template>
<script>
export default {
  name: "ysTag",
  props: {
    text: String,
    closable: Boolean,
    type: String,
    hit: Boolean,
    theme: String,
    disableTransitions: Boolean,
    color: String,
    size: String,
  },
  methods: {
    handleClose(event) {
      this.$emit("close", event);
    },
  },
  computed: {
    tagSize() {
      return this.size || (this.$ELEMENT || {}).size;
    },
  },
};
</script>